package com.sponsorpay.sdk.android.publisher;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.sponsorpay.sdk.android.SponsorPay;
import com.sponsorpay.sdk.android.credentials.SPCredentials;
import com.sponsorpay.sdk.android.publisher.currency.SPCurrencyServerListener;
import com.sponsorpay.sdk.android.publisher.currency.VirtualCurrencyConnector;
import com.sponsorpay.sdk.android.publisher.mbe.SPBrandEngageClient;
import com.sponsorpay.sdk.android.publisher.mbe.SPBrandEngageRequest;
import com.sponsorpay.sdk.android.publisher.mbe.SPBrandEngageRequestListener;
import com.sponsorpay.sdk.android.utils.SPIdException;
import com.sponsorpay.sdk.android.utils.SPIdValidator;
import com.sponsorpay.sdk.android.utils.SponsorPayLogger;
import com.sponsorpay.sdk.android.utils.StringUtils;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

public class SponsorPayPublisher
{
  public static final int DEFAULT_OFFERWALL_REQUEST_CODE = 255;
  public static final int DEFAULT_UNLOCK_OFFERWALL_REQUEST_CODE = 254;
  public static final String PREFERENCES_FILENAME = "SponsorPayPublisherState";
  private static EnumMap<UIStringIdentifier, String> sUIStrings;

  public static int convertDevicePixelsIntoPixelsMeasurement(float paramFloat, Context paramContext)
  {
    return (int)(0.5F + paramFloat * paramContext.getResources().getDisplayMetrics().density);
  }

  public static void displayNotificationForSuccessfullCoinRequest(boolean paramBoolean)
  {
    VirtualCurrencyConnector.shouldShowToastNotification(paramBoolean);
  }

  public static boolean getIntentForMBEActivity(Activity paramActivity, SPBrandEngageRequestListener paramSPBrandEngageRequestListener)
  {
    return getIntentForMBEActivity(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramActivity, paramSPBrandEngageRequestListener);
  }

  public static boolean getIntentForMBEActivity(Activity paramActivity, SPBrandEngageRequestListener paramSPBrandEngageRequestListener, SPCurrencyServerListener paramSPCurrencyServerListener)
  {
    return getIntentForMBEActivity(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramActivity, paramSPBrandEngageRequestListener, null, null, paramSPCurrencyServerListener);
  }

  public static boolean getIntentForMBEActivity(String paramString, Activity paramActivity, SPBrandEngageRequestListener paramSPBrandEngageRequestListener)
  {
    return getIntentForMBEActivity(paramString, paramActivity, paramSPBrandEngageRequestListener, null, null, null);
  }

  public static boolean getIntentForMBEActivity(String paramString1, Activity paramActivity, SPBrandEngageRequestListener paramSPBrandEngageRequestListener, String paramString2, Map<String, String> paramMap, SPCurrencyServerListener paramSPCurrencyServerListener)
  {
    SPBrandEngageClient localSPBrandEngageClient = SPBrandEngageClient.INSTANCE;
    boolean bool = localSPBrandEngageClient.canRequestOffers();
    if (bool)
    {
      SPCredentials localSPCredentials = SponsorPay.getCredentials(paramString1);
      localSPBrandEngageClient.setCurrencyName(paramString2);
      localSPBrandEngageClient.setCustomParameters(paramMap);
      localSPBrandEngageClient.setCurrencyListener(paramSPCurrencyServerListener);
      new SPBrandEngageRequest(localSPCredentials, paramActivity, localSPBrandEngageClient, paramSPBrandEngageRequestListener).askForOffers();
    }
    return bool;
  }

  public static Intent getIntentForOfferWallActivity(Context paramContext, Boolean paramBoolean)
  {
    return getIntentForOfferWallActivity(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramContext, paramBoolean, null, null);
  }

  public static Intent getIntentForOfferWallActivity(Context paramContext, Boolean paramBoolean, String paramString, HashMap<String, String> paramHashMap)
  {
    return getIntentForOfferWallActivity(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramContext, paramBoolean, paramString, paramHashMap);
  }

  public static Intent getIntentForOfferWallActivity(String paramString1, Context paramContext, Boolean paramBoolean, String paramString2, HashMap<String, String> paramHashMap)
  {
    SPCredentials localSPCredentials = SponsorPay.getCredentials(paramString1);
    Intent localIntent = new Intent(paramContext, OfferWallActivity.class);
    localIntent.putExtra("EXTRA_CREDENTIALS_TOKEN_KEY", localSPCredentials.getCredentialsToken());
    if (paramBoolean != null)
      localIntent.putExtra("EXTRA_SHOULD_REMAIN_OPEN_KEY", paramBoolean);
    if (StringUtils.notNullNorEmpty(paramString2))
      localIntent.putExtra("EXTRA_CURRENCY_NAME_KEY", paramString2);
    localIntent.putExtra("EXTRA_KEY_VALUES_MAP", paramHashMap);
    return localIntent;
  }

  public static Intent getIntentForUnlockOfferWallActivity(Context paramContext, String paramString1, String paramString2)
  {
    return getIntentForUnlockOfferWallActivity(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramContext, paramString1, paramString2, null);
  }

  public static Intent getIntentForUnlockOfferWallActivity(String paramString1, Context paramContext, String paramString2, String paramString3, HashMap<String, String> paramHashMap)
  {
    try
    {
      SPIdValidator.validate(paramString2);
      SPCredentials localSPCredentials = SponsorPay.getCredentials(paramString1);
      Intent localIntent = new Intent(paramContext, OfferWallActivity.class);
      localIntent.putExtra("EXTRA_CREDENTIALS_TOKEN_KEY", localSPCredentials.getCredentialsToken());
      localIntent.putExtra("EXTRA_OFFERWALL_TEMPLATE_KEY", "OFFERWALL_TYPE_UNLOCK");
      localIntent.putExtra("EXTRA_UNLOCK_ITEM_ID_KEY", paramString2);
      localIntent.putExtra("EXTRA_UNLOCK_ITEM_NAME_KEY", paramString3);
      localIntent.putExtra("EXTRA_KEY_VALUES_MAP", paramHashMap);
      return localIntent;
    }
    catch (SPIdException localSPIdException)
    {
      throw new RuntimeException("The provided Unlock Item ID is not valid. " + localSPIdException.getLocalizedMessage());
    }
  }

  public static String getUIString(UIStringIdentifier paramUIStringIdentifier)
  {
    if (sUIStrings == null)
      initUIStrings();
    return (String)sUIStrings.get(paramUIStringIdentifier);
  }

  private static void initUIStrings()
  {
    sUIStrings = new EnumMap(UIStringIdentifier.class);
    sUIStrings.put(UIStringIdentifier.ERROR_DIALOG_TITLE, "Error");
    sUIStrings.put(UIStringIdentifier.DISMISS_ERROR_DIALOG, "Dismiss");
    sUIStrings.put(UIStringIdentifier.GENERIC_ERROR, "An error happened when performing this operation");
    sUIStrings.put(UIStringIdentifier.ERROR_LOADING_OFFERWALL, "An error happened when loading the offer wall");
    sUIStrings.put(UIStringIdentifier.ERROR_LOADING_OFFERWALL_NO_INTERNET_CONNECTION, "An error happened when loading the offer wall (no internet connection)");
    sUIStrings.put(UIStringIdentifier.LOADING_INTERSTITIAL, "Loading...");
    sUIStrings.put(UIStringIdentifier.LOADING_OFFERWALL, "Loading...");
    sUIStrings.put(UIStringIdentifier.ERROR_PLAY_STORE_UNAVAILABLE, "You don't have the Google Play Store application on your device to complete App Install offers.");
    sUIStrings.put(UIStringIdentifier.MBE_REWARD_NOTIFICATION, "Thanks! Your reward will be paid out shortly");
    sUIStrings.put(UIStringIdentifier.VCS_COINS_NOTIFICATION, "Congratulations! You've earned %.0f %s!");
    sUIStrings.put(UIStringIdentifier.VCS_DEFAULT_CURRENCY, "coins");
    sUIStrings.put(UIStringIdentifier.MBE_ERROR_DIALOG_TITLE, "Error");
    sUIStrings.put(UIStringIdentifier.MBE_ERROR_DIALOG_MESSAGE_DEFAULT, "We're sorry, something went wrong. Please try again.");
    sUIStrings.put(UIStringIdentifier.MBE_ERROR_DIALOG_MESSAGE_OFFLINE, "Your Internet connection has been lost. Please try again later.");
    sUIStrings.put(UIStringIdentifier.MBE_ERROR_DIALOG_BUTTON_TITLE_DISMISS, "Dismiss");
    sUIStrings.put(UIStringIdentifier.MBE_FORFEIT_DIALOG_TITLE, "");
  }

  public static void requestNewCoins(Context paramContext, SPCurrencyServerListener paramSPCurrencyServerListener)
  {
    requestNewCoins(paramContext, paramSPCurrencyServerListener, null);
  }

  public static void requestNewCoins(Context paramContext, SPCurrencyServerListener paramSPCurrencyServerListener, String paramString)
  {
    requestNewCoins(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramContext, paramSPCurrencyServerListener, null, null, paramString);
  }

  public static void requestNewCoins(String paramString1, Context paramContext, SPCurrencyServerListener paramSPCurrencyServerListener, String paramString2, Map<String, String> paramMap, String paramString3)
  {
    VirtualCurrencyConnector localVirtualCurrencyConnector = new VirtualCurrencyConnector(paramContext, paramString1, paramSPCurrencyServerListener);
    localVirtualCurrencyConnector.setCustomParameters(paramMap);
    localVirtualCurrencyConnector.setCurrency(paramString3);
    localVirtualCurrencyConnector.fetchDeltaOfCoinsForCurrentUserSinceTransactionId(paramString2);
  }

  public static void setCookiesIntoCookieManagerInstance(String[] paramArrayOfString, String paramString, Context paramContext)
  {
    if ((paramArrayOfString == null) || (paramArrayOfString.length == 0));
    while (true)
    {
      return;
      try
      {
        CookieSyncManager.getInstance();
        CookieManager localCookieManager = CookieManager.getInstance();
        SponsorPayLogger.v(AsyncRequest.LOG_TAG, "Setting the following cookies into CookieManager instance " + localCookieManager + " for base URL " + paramString + ": ");
        int i = paramArrayOfString.length;
        for (int j = 0; j < i; j++)
        {
          String str = paramArrayOfString[j];
          localCookieManager.setCookie(paramString, str);
          SponsorPayLogger.v(AsyncRequest.LOG_TAG, str);
        }
      }
      catch (IllegalStateException localIllegalStateException)
      {
        while (true)
          CookieSyncManager.createInstance(paramContext);
      }
    }
  }

  public static void setCustomUIString(UIStringIdentifier paramUIStringIdentifier, int paramInt, Context paramContext)
  {
    setCustomUIString(paramUIStringIdentifier, paramContext.getString(paramInt));
  }

  public static void setCustomUIString(UIStringIdentifier paramUIStringIdentifier, String paramString)
  {
    if (sUIStrings == null)
      initUIStrings();
    sUIStrings.put(paramUIStringIdentifier, paramString);
  }

  public static void setCustomUIStrings(EnumMap<UIStringIdentifier, String> paramEnumMap)
  {
    UIStringIdentifier[] arrayOfUIStringIdentifier = UIStringIdentifier.values();
    int i = arrayOfUIStringIdentifier.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return;
      UIStringIdentifier localUIStringIdentifier = arrayOfUIStringIdentifier[j];
      if (paramEnumMap.containsKey(localUIStringIdentifier))
        setCustomUIString(localUIStringIdentifier, (String)paramEnumMap.get(localUIStringIdentifier));
    }
  }

  public static void setCustomUIStrings(EnumMap<UIStringIdentifier, Integer> paramEnumMap, Context paramContext)
  {
    UIStringIdentifier[] arrayOfUIStringIdentifier = UIStringIdentifier.values();
    int i = arrayOfUIStringIdentifier.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return;
      UIStringIdentifier localUIStringIdentifier = arrayOfUIStringIdentifier[j];
      if (paramEnumMap.containsKey(localUIStringIdentifier))
        setCustomUIString(localUIStringIdentifier, ((Integer)paramEnumMap.get(localUIStringIdentifier)).intValue(), paramContext);
    }
  }

  public static enum UIStringIdentifier
  {
    static
    {
      DISMISS_ERROR_DIALOG = new UIStringIdentifier("DISMISS_ERROR_DIALOG", 1);
      GENERIC_ERROR = new UIStringIdentifier("GENERIC_ERROR", 2);
      ERROR_LOADING_OFFERWALL = new UIStringIdentifier("ERROR_LOADING_OFFERWALL", 3);
      ERROR_LOADING_OFFERWALL_NO_INTERNET_CONNECTION = new UIStringIdentifier("ERROR_LOADING_OFFERWALL_NO_INTERNET_CONNECTION", 4);
      LOADING_INTERSTITIAL = new UIStringIdentifier("LOADING_INTERSTITIAL", 5);
      LOADING_OFFERWALL = new UIStringIdentifier("LOADING_OFFERWALL", 6);
      ERROR_PLAY_STORE_UNAVAILABLE = new UIStringIdentifier("ERROR_PLAY_STORE_UNAVAILABLE", 7);
      MBE_REWARD_NOTIFICATION = new UIStringIdentifier("MBE_REWARD_NOTIFICATION", 8);
      VCS_COINS_NOTIFICATION = new UIStringIdentifier("VCS_COINS_NOTIFICATION", 9);
      VCS_DEFAULT_CURRENCY = new UIStringIdentifier("VCS_DEFAULT_CURRENCY", 10);
      MBE_ERROR_DIALOG_TITLE = new UIStringIdentifier("MBE_ERROR_DIALOG_TITLE", 11);
      MBE_ERROR_DIALOG_MESSAGE_DEFAULT = new UIStringIdentifier("MBE_ERROR_DIALOG_MESSAGE_DEFAULT", 12);
      MBE_ERROR_DIALOG_MESSAGE_OFFLINE = new UIStringIdentifier("MBE_ERROR_DIALOG_MESSAGE_OFFLINE", 13);
      MBE_ERROR_DIALOG_BUTTON_TITLE_DISMISS = new UIStringIdentifier("MBE_ERROR_DIALOG_BUTTON_TITLE_DISMISS", 14);
      MBE_FORFEIT_DIALOG_TITLE = new UIStringIdentifier("MBE_FORFEIT_DIALOG_TITLE", 15);
      UIStringIdentifier[] arrayOfUIStringIdentifier = new UIStringIdentifier[16];
      arrayOfUIStringIdentifier[0] = ERROR_DIALOG_TITLE;
      arrayOfUIStringIdentifier[1] = DISMISS_ERROR_DIALOG;
      arrayOfUIStringIdentifier[2] = GENERIC_ERROR;
      arrayOfUIStringIdentifier[3] = ERROR_LOADING_OFFERWALL;
      arrayOfUIStringIdentifier[4] = ERROR_LOADING_OFFERWALL_NO_INTERNET_CONNECTION;
      arrayOfUIStringIdentifier[5] = LOADING_INTERSTITIAL;
      arrayOfUIStringIdentifier[6] = LOADING_OFFERWALL;
      arrayOfUIStringIdentifier[7] = ERROR_PLAY_STORE_UNAVAILABLE;
      arrayOfUIStringIdentifier[8] = MBE_REWARD_NOTIFICATION;
      arrayOfUIStringIdentifier[9] = VCS_COINS_NOTIFICATION;
      arrayOfUIStringIdentifier[10] = VCS_DEFAULT_CURRENCY;
      arrayOfUIStringIdentifier[11] = MBE_ERROR_DIALOG_TITLE;
      arrayOfUIStringIdentifier[12] = MBE_ERROR_DIALOG_MESSAGE_DEFAULT;
      arrayOfUIStringIdentifier[13] = MBE_ERROR_DIALOG_MESSAGE_OFFLINE;
      arrayOfUIStringIdentifier[14] = MBE_ERROR_DIALOG_BUTTON_TITLE_DISMISS;
      arrayOfUIStringIdentifier[15] = MBE_FORFEIT_DIALOG_TITLE;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.publisher.SponsorPayPublisher
 * JD-Core Version:    0.6.2
 */